#include "LPC11XX.H"
#include "common.h"

void LEDInit()
{
    LPC_SYSCON->SYSAHBCLKCTRL |= (1<<16);  
    LPC_IOCON->PIO2_0 &= ~0x07;    
    LPC_IOCON->PIO2_0 |= 0x00; 
    LPC_IOCON->PIO2_1 &= ~0x07;   
    LPC_IOCON->PIO2_1 |= 0x00; 
    LPC_SYSCON->SYSAHBCLKCTRL &= ~(1<<16);     
    
    LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);     
    LPC_GPIO2->DIR |= (1<<0); 			
    LPC_GPIO2->DATA |= (1<<0); 
    LPC_GPIO2->DIR |= (1<<1); 
    LPC_GPIO2->DATA |= (1<<1); 
}

void PIOINT3_IRQHandler()
{
    if((LPC_GPIO3->MIS & (1<<0))==(1<<0)) // ???P1.9?????
    {
        LED3_ON();
        while(KEY2_DOWN());
        LED3_OFF();
        LPC_GPIO3->IC = (1<<0);  // ???
    }
    if((LPC_GPIO3->MIS & (1<<1))==(1<<1)) // ???P1.10?????
    {
        LED4_ON();
        while(KEY3_DOWN());
        LED4_OFF();
        LPC_GPIO3->IC = (1<<1);  // ???
    }
}

